home *** CD-ROM | disk | FTP | other *** search
- unit DataSetActionsU;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ComCtrls, StdCtrls, Db, DBTables, DBActns, ActnList, ImgList;
-
- type
- TForm1 = class(TForm)
- ActionList1: TActionList;
- DataSetFirst1: TDataSetFirst;
- DataSetLast1: TDataSetLast;
- DataSetNext1: TDataSetNext;
- DataSetPrior1: TDataSetPrior;
- DataSource1: TDataSource;
- Table1: TTable;
- Label1: TLabel;
- Button1: TButton;
- Button2: TButton;
- procedure Table1AfterScroll(DataSet: TDataSet);
- public
- function ExecuteAction(Action: TBasicAction): Boolean; override;
- function UpdateAction(Action: TBasicAction): Boolean; override;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- type
- TActionOperation = (aoUpdate, aoExecute);
-
- function CheckDataSourceAction(Action: TBasicAction;
- Container: TWinControl;
- Operation: TActionOperation): Boolean;
- var
- I: Integer;
- Comp: TComponent;
- begin
- for I := 0 to Container.ComponentCount - 1 do
- begin
- Comp := Container.Components[I];
- if (Comp is TDataSource) and Action.HandlesTarget(Comp) then
- begin
- if Operation = aoUpdate then
- Action.UpdateTarget(Comp)
- else
- Action.ExecuteTarget(Comp);
- Result := True;
- Exit
- end;
- end;
- Result := False;
- end;
-
- function TForm1.ExecuteAction(Action: TBasicAction): Boolean;
- begin
- if CheckDataSourceAction(Action, Self, aoExecute) then
- Result := True
- else
- Result := inherited ExecuteAction(Action)
- end;
-
- procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
- begin
- Label1.Caption := Table1['Company']
- end;
-
- function TForm1.UpdateAction(Action: TBasicAction): Boolean;
- begin
- if CheckDataSourceAction(Action, Self, aoUpdate) then
- Result := True
- else
- Result := inherited UpdateAction(Action)
- end;
-
- end.
-